home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / FILES.SWG / 0001_Renaming Dos Files.pas next >
Encoding:
Pascal/Delphi Source File  |  1996-02-21  |  717 b   |  30 lines

  1.  
  2. program renamer;
  3. uses crt,dos;
  4. var
  5.    f:file;
  6.    s,s2,s3:string;
  7.    on:integer;
  8.    found:searchrec;
  9. begin
  10.      on:=1;
  11.      write('Start of name: ');
  12.      readln(s);
  13.      findfirst('*.*',anyfile,found);
  14.      while doserror=0 do begin
  15.            if found.attr and directory=0 then begin
  16.               assign(f,found.name);
  17.               str(on,s2);
  18.               while length(s2)+length(s)<8 do s2:='0'+s2;
  19.               s2:=s+s2;
  20.               s3:=found.name;
  21.               if pos('.',s3)=0 then s3:=s3+'.';
  22.               s2:=s2+copy(s3,pos('.',s3),length(s3));
  23.               rename(f,s2);
  24.               inc(on);
  25.               end;
  26.            findnext(found);
  27.            end;
  28.      end.
  29.  
  30.